package com.atguigu.utils.deadLockDemo;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

class A {

    Lock lockA = new ReentrantLock();

    Lock lockB = new ReentrantLock();

    public void a() {
        lockA.lock();
        try {
            try {
                System.out.println("aaa");
                lockB.lock();
            } finally {
                lockB.unlock();
            }
        } finally {
            lockA.unlock();
        }
    }

    public void b() {
        lockB.lock();
        try {
            try {
                System.out.println("bbb");
                lockA.lock();
            } finally {
                lockA.unlock();
            }
        } finally {
            lockB.unlock();
        }
    }
}